package dao.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

// import bean.Student;

public class Mysql {

    /**
     * 驱动类名称
     */
    private static final String DRIVER_CLASS = "com.mysql.jdbc.Driver";

    /**
     * 数据库连接字符串
     */
    private static final String DATABASE_URL = "jdbc:mysql://localhost:3306/student?characterEncoding=utf8";

    /**
     * 数据库用户名
     */
    private static final String USER_NAME = "root";

    /**
     * 数据库密码
     */
    private static final String PASSWORD = "123321";

    /**
     * 数据库连接类
     */
    private static Connection conn;

    // 加载驱动
    static {
        try {
			Class.forName(DRIVER_CLASS);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

    // 取得连接
    public static Connection getConnection() throws SQLException {
        conn = DriverManager.getConnection(DATABASE_URL, USER_NAME, PASSWORD);
        return conn;
    }
}
